<?php
$company			= array('id'=>'bill_company', 'class'=>'span6 form-control', 'name'=>'company', 'value'=> set_value('company'));
$first				= array('id'=>'bill_firstname', 'class'=>'span3 form-control', 'name'=>'firstname', 'value'=> set_value('firstname'));
$last				= array('id'=>'bill_lastname', 'class'=>'span3 form-control', 'name'=>'lastname', 'value'=> set_value('lastname'));
$fullname			= array('id'=>'bill_fullname', 'class'=>'span3 form-control', 'name'=>'fullname', 'value'=> set_value('fullname'));
$email				= array('id'=>'bill_email', 'class'=>'span3 form-control', 'name'=>'email', 'value'=>set_value('email'));
$phone				= array('id'=>'bill_phone', 'class'=>'span3 form-control', 'name'=>'phone', 'value'=> set_value('phone'));
$gender_female		= array('id'=>'inlineCheckbox3', 'class'=>'', 'name'=>'gender', 'value'=>0);
$gender_male		= array('id'=>'inlineCheckbox3',"checked"=>true, 'class'=>'', 'name'=>'gender', 'value'=>1);
$birth				= array('id'=>'date_birth', 'class'=>'span3 form-control', 'name'=>'birth', 'value'=>set_value('birth'));
echo theme_css('jquery-ui.css', true);
echo theme_js('jquery-ui.js', true);?>
<style>.checkbox-inline input{position:absolute;margin-left:-20px}</style>
<!------------------------- Content home --------------------------->
<div class="content_wp">
	<div class="container">
        	<div class="breadcrumb_wp">
            	<ol class="breadcrumb">
                  <li><a href="#">Trang Chủ</a></li>
                  <li class="active">Đăng ký</li>
                </ol>
            </div>
            <div class="gio_hang_wp">
            	<div class="title_article">
                	<h3><i class="fa fa-shopping-cart"></i> Đăng ký</h3>
                </div>
                <?php echo form_open(REGISTER, array('id' => 'dang-ky')); ?>
                <h2 class="title_cart">Thông tin khách hàng và đăng ký thành viên mới</h2>
                <p>Vui lòng nhập các mục sau đây và nhấn vào nút "Đăng ký".</p>
                <p><input id="rule" type="checkbox" /> Tôi đã đọc và đồng ý với <a href="<?php echo site_url("quy-dinh-su-dung")?>" target="_blank">quy định sử dụng</a> của Plus Mainichi.</p>
				<p><span class="red">*</span> Yêu cầu bắt buộc nhập thông tin.</p>
                <div class="rege_new_member_wp form_register">
                	<div id="messager">
						<?php if(!empty($error_messger)){?>
                            <div class="alert alert-error">
                                <a class="close" data-dismiss="alert">×</a>
                                <?php echo $error_messger?>
                            </div>
                        <?php }?>
                    </div>
                	
                    <input type="hidden" name="submitted" value="submitted" />
                    <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />                       
                    <div class="form-group">
                    	<label for="account_fullname"><?php echo lang('account_fullname');?> <span class="red">*</span></label>
						<?php echo form_input($fullname);?>
                        <div class="clear"></div>
					</div>
                     <div class="form-group">
						<label for="account_gender"> <?php echo lang("account_birth")?> <span class="red">*</span></label>
                        <div class="clear"></div>
                        <?php echo form_input($birth);?>
                         <div class="clear"></div>
                     </div>
                     <div class="form-group">
                     	<label style="float: left;margin-top: 1px;margin-right: 20px;" for="account_gender"> <?php echo lang("account_gender")?></label>
                        <label class="checkbox-inline"><?php echo  form_radio($gender_male)?><?php echo lang("acccount_gender_male")?></label>
                       	<label class="checkbox-inline"><?php echo  form_radio($gender_female)?><?php echo lang("acccount_gender_female")?></label>
                     </div>
                    <div class="form-group">
						<label for="account_email"><?php echo lang('account_email');?>  (Dùng đăng nhập website) <span class="red">*</span></label>
						<?php echo form_input($email);?>
                         <div class="clear"></div>
                    </div>
					<div class="form-group">
						<label for="account_phone"><?php echo lang('account_phone');?> <span class="red">*</span></label>
						<?php echo form_input($phone);?> <div class="clear"></div>
                    </div>
					
                    <div class="form-group">
						<label for="account_password"><?php echo lang('account_password');?> <span class="red">*</span></label>
						<input cl type="password" name="password" value="" class="span3 form-control" autocomplete="off" />
                         <div class="clear"></div>
					</div>
					<div class="form-group">
						<label for="account_confirm"><?php echo lang('account_confirm');?> <span class="red">*</span></label>
						<input type="password" name="confirm" value="" class="span3 form-control" autocomplete="off" />
                         <div class="clear"></div>
					</div>
                    <div class="form-group">
						<input type="checkbox" name="email_subscribe" value="1" <?php echo set_radio('email_subscribe', '1', TRUE); ?>/> <?php echo lang('account_newsletter_subscribe');?>
					</div>
                     <input type="submit" value="<?php echo lang('form_register');?>" class="btn btn-primary" />
                </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script language="javascript">
$("#date_birth").datepicker({
	dateFormat:"dd/mm/yy",	
	changeYear: true,
	changeMonth:true,
	monthNamesShort:[1,2,3,4,5,6,7,8,9,10,11,12],
	yearRange:"1950:-10",
	defaultDate:'01/01/1950',
});
$(".btn-primary").click(function(){
	var fullname 		  = $("#dang-ky input[name='fullname']").val();
	var birth 	  		  = $("#dang-ky input[name='birth']").val();
	var email 	  		  = $("#dang-ky input[name='email']").val();
	var phone 	  		  = $("#dang-ky input[name='phone']").val();
	var pass 	  		  = $("#dang-ky input[name='password']").val();
	var confirm_pass 	  = $("#dang-ky input[name='confirm']").val();
	var $html_error = "";
	if(fullname == null || fullname == "")
		$html_error += "<div><?php echo lang("error_fullname_empty")?></div>";
	if(birth == null || birth == "")
		$html_error += "<div><?php echo lang("error_birth_empty")?></div>";
	if(phone == null || phone == "")
		$html_error += "<div><?php echo lang("error_phone_empty")?></div>";
	if(email == null || email == "")
		$html_error += "<div><?php echo lang("error_email_empty")?></div>";
	else{
		regex = "/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/";
		
		if(!regex.test(email)) {
			$html_error += "<div><?php echo lang("error_email_type")?></div>";
		}
	}
	if(pass == null || pass == "")
		$html_error += "<div><?php echo lang("error_phone_empty")?></div>";
	else{
		if(pass != confirm_pass)	
		$html_error += "<div><?php echo lang("error_confirm_password")?></div>";
	}
	if($html_error == ""){
		return true;
	}
	else{
		$('html, body').animate({scrollTop: $(".gio_hang_wp").offset().top}, 0);
		$("#messager").html("<div class='alert alert-error'> <a class='close' data-dismiss='alert'>×</a>"+$html_error+"</div>");
		return false;
	}
});
$("#dang-ky").submit(function() {
	if (document.getElementById("rule").checked) {
       return true;
    }
	else {
		var agree = confirm("Bạn đồng ý với quy định sử dụng của Plus Mainichi?");
		return agree;
	}
});

</script>